package com.soilflow.know.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.soilflow.common.domain.KnowsReportReply;
import com.soilflow.common.domain.dto.KnowsReportReplyDto;
import com.soilflow.common.domain.vo.KnowsReportReplyVo;
import com.soilflow.common.utils.bean.BeanUtils;
import com.soilflow.know.mapper.KnowsReportReplyMapper;
import com.soilflow.know.service.KnowsReportReplyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class KnowsReportReplyServiceImpl extends ServiceImpl<KnowsReportReplyMapper, KnowsReportReply> implements KnowsReportReplyService {

    @Resource
    private KnowsReportReplyMapper knowsReportReplyMapper;

    @Override
    public List<KnowsReportReplyVo> reportReplyList(KnowsReportReplyDto dto) {
        return knowsReportReplyMapper.reportReplyList(dto);
    }

    @Override
    public void addReportReply(KnowsReportReplyDto dto) {
        KnowsReportReply knowsReportReply = new KnowsReportReply();
        BeanUtils.copyBeanProp(dto,knowsReportReply);
        knowsReportReplyMapper.insert(knowsReportReply);
    }

    @Override
    public void updateReportReply(KnowsReportReplyDto dto) {
        KnowsReportReply knowsReportReply = new KnowsReportReply();
        BeanUtils.copyBeanProp(dto,knowsReportReply);
        knowsReportReply.setId(dto.getId());
        knowsReportReplyMapper.updateById(knowsReportReply);
    }

    @Override
    public KnowsReportReplyVo getReportReplyById(Long id) {
        KnowsReportReply knowsReportReply = knowsReportReplyMapper.selectById(id);
        KnowsReportReplyVo vo = new KnowsReportReplyVo();
        BeanUtils.copyBeanProp(knowsReportReply,vo);
        return vo;
    }
}
